Each KCL object belongs to one of the 22 implementation types. The implementation types are shown in Table 4-1 with the corresponding Common Lisp data types. In the table, the compiled functions are divided into two implementation types; cfun is the type of compiled functions without environment, and cclosure is the type of compiled functions with environment (i.e., the type of compiled closures). spice is the type of internal data used by KCL, and does not correspond to any Common Lisp data type.
Implementation Type | Common Lisp Data Type |
cons | cons |
fixnum | fixnum |
bignum | bignum |
ratio | ratio |
short-float | short-float |
long-float | long-float (= double-float = single-float) |
complex | complex |
character | character |
symbol | symbol |
package | package |
hash-table | hash-table |
array | (and array (not vector)) |
vector | (and vector (not string) (not bit-vector)) |
string | string |
bit-vector | bit-vector |
structure | structure |
stream | stream |
random-state | random-state |
readtable | readtable |
cfun | compiled-function without environment |
cclosure | compiled-function with environment |
spice | none |
Each object is represented by a cell allocated in the heap area of the interpreter. The size of the cell is determined by the implementation type of the object.
The implementation types are classified according to the size of the cells for the objects of the type, as shown in Table 4-2. The size of the cells in the same type class is the same.
Class | Implementation Types |
1 | cons bignum ratio long-float complex |
2 | fixnum short-float character random-state readtable spice |
3 | symbol package |
4 | array hash-table vector bit-vector stream pathname cclosure |
5 | string cfun |
6 | structure |
For objects of the (implementation) types readtable, symbol, package, array, hash-table, vector, bit-vector, stream, cclosure, string, cfun, and structure, the cell is simply a header of the object. The body of the object is allocated separately from the cell and is managed in a different manner. The memory space occupied by the body of such an object is called a block . A block is either contiguous or relocatable depending on the area in which it is allocated. The difference between the two areas will be explained below. Table 4-3 lists these types, along with the contents of the body and the kind of the block.
Type | Body | Block |
readtable | read table | contiguous |
symbol | symbol name | relocatable |
package | hash table | contiguous |
array | array body | relocatable or contiguous |
hash-table | hash table | relocatable |
vector | vector body | relocatable or contiguous |
bit-vector | bit-vector body | relocatable or contiguous |
stream | I/O buffer | contiguous |
cclosure | code | contiguous |
string | string body | relocatable or contiguous |
cfun | code | contiguous |
structure | structure body | relocatable |
Usually, the body of an array, a vector, a bit-vector, or a string is allocated as a relocatable block. In KCL, the function make-array takes an extra keyword argument :static. If the :static argument is supplied with a non- nil value, then the body of the array is allocated as a contiguous block.